#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <time.h>
#include "../common.h"
extern "C" {
#include "../yy.h"
}
#include "../sizer.h"
#include "../pcoder.h"
#include "../display.h"
#include "pic16e.h"
#include "pic16e_asm.h"
#include "pic16e_inst.h"

static int convertCompare(int code)
{
	switch ( code )
	{
		case P_JGE:	return P_JLE;
		case P_JLT:	return P_JGT;
		case P_JGT:	return P_JLT;
		case P_JLE:	return P_JGE;
		default:	return code;
	}
}

static bool signedConst(int size, Item *ip)
{
	if ( ip->acceSign() )
		return true;

	unsigned int n = ip->val.i;
	unsigned int m = (1 << (size*8 - 1)) - 1;
	return (n <= m);
}

void PIC16E :: cmpJump(int code, Item *ip0, Item *ip1, Item *ip2)
{
	char *inst= (code == P_JEQ)? _BEQ: _BNE;
	parseJumpItem(ip0, 1);
	parseJumpItem(ip1, 2);
	ASM_CODE(inst,_R_A4, _R_A5,ip2->val.s);
}

void PIC16E :: cmpJumpConst(int code, Item *ip0, Item *ip1, Item *ip2)
{
;
}

void PIC16E :: cmpJump(bool signedCmp, int code, Item *ip2)
{
}